-- This file is a part of my personal neovim configuration.
-- It contains my personal snippets for various languages and file types.

local ls = require("luasnip")
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node

-- Rust 组
local rust_snippets = {
  s("rustfunction", {
    t("fn "),
    i(1, "func_name"),
    t("("),
    i(2, "variables"),
    t(":"),
    i(3, "type"),
    t(") {"),
    t({ "", "    " }),
    i(0),
    t({ "", "}" }),
  }),

  s("rustfunction", {
    t("fn "),
    i(1, "func_name"),
    t("("),
    i(2, "var1"),
    t(":"),
    i(3, "type"),
    t(", "),
    i(4, "var2"),
    t(":"),
    i(5, "type"),
    t(") {"),
    t({ "", "    " }),
    i(0),
    t({ "", "}" }),
  }),
}

-- Markdown 组
local markdown_snippets = {
  s(".toc", {
    t({ "", "---" }), -- 插入分隔线
    t({ "", "", "[[__TOC__]]", "", "" }), -- 插入目录和换行
    t({ "---", "" }), -- 插入另一个分隔线
    t({ "", "" }), -- 插入两个空行
    i(0), -- 光标位置
  }),
}

ls.add_snippets("rust", rust_snippets)
ls.add_snippets("markdown", markdown_snippets)

return {
  rust = {
    s = rust_snippets,
  },
  markdown = {
    s = markdown_snippets,
  },
}
